package com.br.gapps.crm.repository;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.br.gapps.crm.entity.Customer;

public class CustomerRepository extends Repository{

	public CustomerRepository(EntityManager manager) { 
		this.setManager(manager);
	}
	
	public CustomerRepository(){
	}
	
	public void adiciona(Customer c) {
		this.getManager().persist(c);
	}
	public Customer busca(Integer id) {
		return this.getManager().find(Customer.class, id);
	}
	@SuppressWarnings("unchecked")
	public List<Customer> findAll() {
		Query query = this.getManager().createQuery("SELECT e FROM Customer e");
		return query.getResultList();
	}
	public void remove(Customer c){
		this.getManager().remove(c);
	}

}
